#include "TcpConn.h"
#include <QThread>
#include <QTcpSocket>
#include "TcpBusiness.h"

TcpConn::TcpConn(QObject *parent)
	: QTcpServer(parent)
{}

TcpConn::~TcpConn()
{}

void TcpConn::incomingConnection(qintptr socketDescriptor)
{
	QThread* thread = new QThread(this);
	TcpBusiness* work = new TcpBusiness(socketDescriptor);
	work->moveToThread(thread);

	connect(thread, &QThread::finished, work, &QObject::deleteLater);
	connect(thread, &QThread::finished, thread, &QThread::deleteLater);

	connect(this, &TcpConn::start, work, &TcpBusiness::creatConn);
	thread->start();

	emit start();
}
